<?php

/**
 * Contacts filter form base class.
 *
 * @package    HomeShow
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseContactsFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'firstname'                 => new sfWidgetFormFilterInput(),
      'lastname'                  => new sfWidgetFormFilterInput(),
      'emailaddress'              => new sfWidgetFormFilterInput(),
      'preferredaddress'          => new sfWidgetFormFilterInput(),
      'preferredphone'            => new sfWidgetFormFilterInput(),
      'preferredmethod'           => new sfWidgetFormFilterInput(),
      'address_idaddress'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'add_empty' => true)),
      'phonenumber_idphonenumber' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Phonenumber'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'firstname'                 => new sfValidatorPass(array('required' => false)),
      'lastname'                  => new sfValidatorPass(array('required' => false)),
      'emailaddress'              => new sfValidatorPass(array('required' => false)),
      'preferredaddress'          => new sfValidatorPass(array('required' => false)),
      'preferredphone'            => new sfValidatorPass(array('required' => false)),
      'preferredmethod'           => new sfValidatorPass(array('required' => false)),
      'address_idaddress'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Address'), 'column' => 'idaddress')),
      'phonenumber_idphonenumber' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Phonenumber'), 'column' => 'idphonenumber')),
    ));

    $this->widgetSchema->setNameFormat('contacts_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contacts';
  }

  public function getFields()
  {
    return array(
      'contact_id'                => 'Number',
      'firstname'                 => 'Text',
      'lastname'                  => 'Text',
      'emailaddress'              => 'Text',
      'preferredaddress'          => 'Text',
      'preferredphone'            => 'Text',
      'preferredmethod'           => 'Text',
      'address_idaddress'         => 'ForeignKey',
      'phonenumber_idphonenumber' => 'ForeignKey',
    );
  }
}
